// pages/caicaicai/index.js
let numComputer, numUser, min=0, max=100, list=[]
Page({
	data:{
		min: 0,
		max: 100,
		list: [],
	},
    onLoad(options) {
		numComputer=parseInt(Math.random()*99)+1 
		console.log('计算机心里想的数据：',numComputer)
	},

	input(e){  
		numUser=parseInt(e.detail.value||0)
		console.log('用户猜想的数据：',numUser)
	},
	caicaicai(e){
		let message=null
		if(numComputer>numUser){
			message='Sorry, 猜小啦~'
			if(min<numUser)min=numUser
		}else if(numComputer<numUser){
			message='Sorry, 猜大啦~'
			if(numUser<max)max=numUser
		}else{
			message='恭喜你, 猜对啦~'
		}
		list.push(numUser)
		console.log('执行猜猜猜结果：',message)
		this.setData({ 
			result: message,
			focus: true, 
			value: '', 
			lastNumber: numUser, 
			min: min,
			max, 
			list,
		})
	}
})